package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 月卡
 */
public class MonthCardCfg extends BaseCfg<MonthCardCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "month_card";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.MonthCardCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 9;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","升级商品id（如月卡升为季卡，则填季卡id）","领取礼包","可领天数","卡类型(月卡、季卡、年卡)","购买时赠送道具","前台：icon","前台：name","前台：des1",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","upgradeId","gainItem","days","type","presentItem","icon","name","des1",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","upgradeId","gainItem","days","type","presentItem","icon","name","des1",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,1182436439,-1875680462,3076183,3575610,-1225158034,3226745,3373707,3079775,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","Map","int","int","Map","String","String","String",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Map.class,Integer.class,Integer.class,Map.class,String.class,String.class,String.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 升级商品id（如月卡升为季卡，则填季卡id）
	 */
	private int upgradeId;
	
	/**
	 * 领取礼包
	 */
	private Map gainItem;
	
	/**
	 * 可领天数
	 */
	private int days;
	
	/**
	 * 卡类型(月卡、季卡、年卡)
	 */
	private int type;
	
	/**
	 * 购买时赠送道具
	 */
	private Map presentItem;
	
	/**
	 * 前台：icon
	 */
	private String icon;
	
	/**
	 * 前台：name
	 */
	private String name;
	
	/**
	 * 前台：des1
	 */
	private String des1;
	
	
	
	public static MonthCardCfg builder() {
		MonthCardCfg monthCardCfg = new MonthCardCfg();
		return monthCardCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 升级商品id（如月卡升为季卡，则填季卡id）
	 */
	public int getUpgradeId() {
		return upgradeId;
	}
	
	/**
	 * 领取礼包
	 */
	public Map getGainItem() {
		return gainItem;
	}
	
	/**
	 * 可领天数
	 */
	public int getDays() {
		return days;
	}
	
	/**
	 * 卡类型(月卡、季卡、年卡)
	 */
	public int getType() {
		return type;
	}
	
	/**
	 * 购买时赠送道具
	 */
	public Map getPresentItem() {
		return presentItem;
	}
	
	/**
	 * 前台：icon
	 */
	public String getIcon() {
		return icon;
	}
	
	/**
	 * 前台：name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * 前台：des1
	 */
	public String getDes1() {
		return des1;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.upgradeId;
        values[2] = this.gainItem;
        values[3] = this.days;
        values[4] = this.type;
        values[5] = this.presentItem;
        values[6] = this.icon;
        values[7] = this.name;
        values[8] = this.des1;
        return values;
	}
	
	protected MonthCardCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.upgradeId = (int)vals[1];
		this.gainItem = (Map)vals[2];
		this.days = (int)vals[3];
		this.type = (int)vals[4];
		this.presentItem = (Map)vals[5];
		this.icon = (String)vals[6];
		this.name = (String)vals[7];
		this.des1 = (String)vals[8];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.upgradeId);
        map.put(keys[2], this.gainItem);
        map.put(keys[3], this.days);
        map.put(keys[4], this.type);
        map.put(keys[5], this.presentItem);
        map.put(keys[6], this.icon);
        map.put(keys[7], this.name);
        map.put(keys[8], this.des1);
        return map;
    }
    
    protected MonthCardCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.upgradeId = (int)map.get(keys[1]);
   		this.gainItem = (Map)map.get(keys[2]);
   		this.days = (int)map.get(keys[3]);
   		this.type = (int)map.get(keys[4]);
   		this.presentItem = (Map)map.get(keys[5]);
   		this.icon = (String)map.get(keys[6]);
   		this.name = (String)map.get(keys[7]);
   		this.des1 = (String)map.get(keys[8]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.upgradeId);
        obj.put(keys[2], this.gainItem);
        obj.put(keys[3], this.days);
        obj.put(keys[4], this.type);
        obj.put(keys[5], this.presentItem);
        obj.put(keys[6], this.icon);
        obj.put(keys[7], this.name);
        obj.put(keys[8], this.des1);
        return obj;
    }
    
    protected MonthCardCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.upgradeId = obj.getIntValue(keys[1]);
		this.gainItem = obj.getObject(keys[2],Map.class);
	    this.days = obj.getIntValue(keys[3]);
	    this.type = obj.getIntValue(keys[4]);
		this.presentItem = obj.getObject(keys[5],Map.class);
	    this.icon = obj.getString(keys[6]);
	    this.name = obj.getString(keys[7]);
	    this.des1 = obj.getString(keys[8]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.upgradeId);
	    byteBuf.writeObject(this.gainItem);
	    byteBuf.writeInt(this.days);
	    byteBuf.writeInt(this.type);
	    byteBuf.writeObject(this.presentItem);
	    byteBuf.writeString(this.icon);
	    byteBuf.writeString(this.name);
	    byteBuf.writeString(this.des1);
    }
	
	protected MonthCardCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.upgradeId = byteBuf.readInt(null);
	    this.gainItem = (Map)byteBuf.readObject();
	    this.days = byteBuf.readInt(null);
	    this.type = byteBuf.readInt(null);
	    this.presentItem = (Map)byteBuf.readObject();
	    this.icon = byteBuf.readString(null);
	    this.name = byteBuf.readString(null);
	    this.des1 = byteBuf.readString(null);
	    return this;
	}
	
	public MonthCardCfg deepCopy(){
		MonthCardCfg monthCardCfg = null;
		try {
			monthCardCfg = (MonthCardCfg) super.clone();
		    monthCardCfg.gainItem = ToolCopy.copyObject(this.gainItem);
		    monthCardCfg.presentItem = ToolCopy.copyObject(this.presentItem);
			return monthCardCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return monthCardCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
